#e
#Title[\ufIVOtv]
#Text[]
#ScriptVersion[2]
script_enemy_main
{
	let cx=GetCenterX();//STGV[̒SxW擾
	let cy=GetCenterY();//STGV[̒SyW擾
	let imgExRumia=GetCurrentScriptDirectory~"img\ExRumia.png";
	let imgExRumiaBack=GetCurrentScriptDirectory~"img\ExRumiaBack.png";
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetScore(30000);
		SetLife(700);
		SetDamageRate(10,0);
		SetMovePosition02(cx,cy-120,60);
		SetTimer(60);
		SetGraphicRect(1,1,64,64);
		SetInvincibility(120);
		LoadGraphic(imgExRumia);
		SetTexture(imgExRumia);	
		shottask;
		shottask2;
		shottask3;
		bombtask;
		CutIn(YOUMU,"\ufIVOtv",0,0,0,0,0);//XyJ[h\
	}
	@MainLoop
	{
		yield;
	}
	@Finalize
	{
		loop(8)
		{
			CreateItem(ITEM_SCORE,cx+rand(-100,100),rand(20,100));
		}
	}
	@DrawLoop
	{
		SetGraphicRect(1,1,64,64);
		DrawGraphic(GetX(),GetY());
	}
	task shottask
	{
		let s=0;
		wait(120);
		CreateObjLaser(GetX,GetY,0,0,2,152,0);
		wait(60);
		loop
		{
			wait(6);
			CreateShotA(s,GetClipMinX,GetPlayerY,0);
			SetShotDataA(s,0,2,0,0,0,1,92);
			FireShot(s);
		}
	}
	task shottask2
	{
		let s=0;
		wait(180);
		loop
		{
			wait(180);
			let angle=rand(0,360);
			loop(120)
			{
				CreateShotA(s,GetX,GetY,0);
				SetShotDataA(s,0,1,angle,0,0,0,49);
				FireShot(s);
				angle+=3;
			}
		}
	}
	task shottask3
	{
		let s=0;
		let x=0;
		let y=0;
		wait(180);
		loop
		{
			x=GetClipMinX+48;
			y=GetClipMinY;
			loop(4)
			{
				CreateShot01(x,GetClipMinY,2,90,92,0);
				x+=96;
			}
			loop(5)
			{
				CreateShot01(GetClipMinX,y,2,0,92,0);
				y+=112;
			}
			wait(18);
		}
	}
	task bombtask
	{
		loop
		{
			if(OnBomb)
			{
				SetAlpha(64);
				SetDamageRate(0,0);
			}
			else
			{
				SetAlpha(255);
				SetDamageRate(10,0);
				SetCollisionA(GetX(),GetY(),24);
				SetCollisionB(GetX(),GetY(),24);
			}
			yield;
		}
	}
	task CreateObjLaser(let x, let y, let angle, let length,let width, let graphic, let delay)
	{
		let obj = Obj_Create(OBJ_LASER);
		Obj_SetPosition(obj, x, y);
		Obj_SetSpeed(obj, 0);
		Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, graphic);
		ObjShot_SetDelay(obj, delay);
		ObjLaser_SetLength(obj, length);
		ObjLaser_SetWidth(obj, width);
		Obj_SetCollisionToPlayer(obj,false);
		ObjLaser_SetSource(obj, false);
	        loop(delay){ yield; }
		while(!Obj_BeDeleted(obj))
		{
			if(length<GetClipMaxX)
			{
				length+=10;
			}
			Obj_SetPosition(obj,GetClipMinX, GetPlayerY);
			ObjLaser_SetLength(obj, length);
			yield;
		}
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}